import java.util.*;
public class ColorManager{
    private static ColorManager instance=null;
    private  Hashtable ht=new Hashtable();
    private ColorManager(){
        
    }
    public static ColorManager getInstance(){
        if (instance==null){
            System.out.println("颜色池初始化。");
            instance=new ColorManager();
            instance.setColorManager();    
        }else{
            System.out.println("颜色池已存在。");
        }
        return instance;
    }
    private void setColorManager(){//可不可以通过配置文件把颜色弄进颜色池?
        ht.put("red",new Red());    
        ht.put("blue",new Blue());
        ht.put("green",new Green());
    }
    public void addColor(String key,Color obj){
        ht.put(key,obj);
    }
    public Color getColor(String key){//这个留下来用来给客户调用
        return (Color)((Color)ht.get(key)).clone();
    }

}
